<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Box extends Model
{
    protected $item = [];

    public function __construct($item = [])
    {
        $this->item = $item;
    }

    public function has($item) {
        return in_array($item, $this->item);
    }

    public function takeOne()
    {
        return array_shift($this->item);
    }

    public function startWith($letter)
    {
        return array_filter($this->item, function($item) use ($letter){
            return stripos($item, $letter) === 0;
        });
    }
}
